import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import {JVxeTypes,JVxeColumn} from '/@/components/jeecg/JVxeTable/types'
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '单价的名称',
    align:"center",
    dataIndex: 'name'
   },
   {
    title: '费率类型',
    align:"center",
    dataIndex: 'type_dictText'
   },
   {
    title: '备注',
    align:"center",
    dataIndex: 'remark'
   },
   {
    title: '是否开启模板结算时间结算0 开启 1 关闭 默认关闭 按照抄表时间扣款',
    align:"center",
    dataIndex: 'isSettlement'
   },
   {
    title: '结算时间 cron 表达式',
    align:"center",
    dataIndex: 'settlementCron'
   },
   {
    title: '逻辑删除',
    align:"center",
    dataIndex: 'isDel'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
     {
      label: "创建日期",
      field: "createTime",
      component: 'RangePicker',
      componentProps: {
          showTime:true
      },
      colProps: {span: 6},
	},
	{
      label: "单价的名称",
      field: "name",
      component: 'Input',
      colProps: {span: 6},
 	},
	{
      label: "费率类型",
      field: "type",
      component: 'JDictSelectTag',
      componentProps:{
          dictCode:"dj_type"
      },
      colProps: {span: 6},
 	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '单价的名称',
    field: 'name',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: false},
                 {...rules.duplicateCheckRule('bw_dj', 'name',model,schema)[0]},
          ];
     },
  },
  {
    label: '费率类型',
    field: 'type',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"dj_type"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入费率类型!'},
          ];
     },
  },
  {
    label: '备注',
    field: 'remark',
    component: 'Input',
  },
  {
    label: '是否开启模板结算时间结算0 开启 1 关闭 默认关闭 按照抄表时间扣款',
    field: 'isSettlement',
    component: 'InputNumber',
  },
  {
    label: '结算时间 cron 表达式',
    field: 'settlementCron',
    component: 'Input',
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];
//子表单数据
//子表表格配置
export const bwDjlbColumns: JVxeColumn[] = [
    {
      title: '排序',
      key: 'level',
      type: JVxeTypes.inputNumber,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
        validateRules: [
          { required: true, message: '${title}不能为空' },
        ],
    },
    {
      title: '起码',
      key: 'qm',
      type: JVxeTypes.inputNumber,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
        validateRules: [
          { required: true, message: '${title}不能为空' },
        ],
    },
    {
      title: '止码',
      key: 'zm',
      type: JVxeTypes.inputNumber,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
        validateRules: [
          { required: true, message: '${title}不能为空' },
        ],
    },
    {
      title: '单价（吨，度）',
      key: 'dj',
      type: JVxeTypes.inputNumber,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
        validateRules: [
          { required: true, message: '${title}不能为空' },
        ],
    },
    {
      title: '服务费（吨，度）',
      key: 'djService',
      type: JVxeTypes.inputNumber,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
  ]
